import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { deviceInfoListData } from '/@/api/orther/device/deviceInfo';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('客户选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  schemas: [
    {
      label: t('设备序列号'),
      field: 'deviceSerial',
      component: 'Input',
    },
    {
      label: t('设备名称'),
      field: 'deviceName',
      component: 'Input',
    },
    {
      label: t('设备位置'),
      field: 'deviceLocation',
      component: 'Input',
      ifShow: false,
    },
    {
      label: t('UIKIT主题'),
      field: 'uikitTemplate',
      component: 'Select',
      componentProps: {
        dictType: 'zf_device_uikit',
      },
    },
    {
      label: t('状态'),
      field: 'status',
      component: 'Select',
      componentProps: {
        dictType: 'sys_search_status',
        allowClear: true,
      },
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('设备序列号'),
    dataIndex: 'deviceSerial',
    key: 'a.device_serial',
    sorter: true,
    width: 150,
    align: 'left',
  },
  {
    title: t('设备名称'),
    dataIndex: 'deviceName',
    key: 'a.device_name',
    sorter: true,
    width: 230,
    align: 'left',
  },
  {
    title: t('设备位置'),
    dataIndex: 'deviceLocation',
    key: 'a.device_location',
    sorter: true,
    width: 150,
    align: 'left',
  },
  // {
  //   title: t('appkey'),
  //   dataIndex: 'appkey',
  //   key: 'a.appkey',
  //   sorter: true,
  //   width: 200,
  //   align: 'left',
  // },
  // {
  //   title: t('secret'),
  //   dataIndex: 'secret',
  //   key: 'a.secret',
  //   sorter: true,
  //   width: 200,
  //   align: 'left',
  // },
  {
    title: t('播放地址(高清)'),
    dataIndex: 'previewUrlHd',
    key: 'a.preview_url_hd',
    sorter: true,
    width: 200,
    align: 'left',
  },
  {
    title: t('播放地址(流畅)'),
    dataIndex: 'previewUrlSd',
    key: 'a.preview_url_sd',
    sorter: true,
    width: 200,
    align: 'left',
  },
  {
    title: t('UIKIT主题模板'),
    dataIndex: 'uikitTemplate',
    key: 'a.uikit_template',
    dictType: 'zf_device_uikit',
    sorter: true,
    width: 200,
    align: 'left',
  },
  {
    title: t('备注'),
    dataIndex: 'remarks',
    key: 'a.remarks',
    sorter: true,
    width: 200,
    align: 'left',
  },
  {
    title: t('状态'),
    dataIndex: 'status',
    key: 'a.status',
    sorter: true,
    width: 100,
    align: 'center',
    dictType: 'sys_search_status',
    fixed: 'right',
  },
];

const tableProps: BasicTableProps = {
  api: deviceInfoListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'deviceSerial',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'deviceSerial',
  itemName: 'deviceName',
};
